package cn.bluech.example.ui

import android.content.Intent
import android.graphics.BitmapFactory
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import cn.bluech.example.R
import cn.bluech.example.global.Route
import cn.bluech.lib.ui.widget.datetimepicker.DatePickerDialog
import cn.bluech.lib.utils.ShortcutUtils
import kotlinx.android.synthetic.main.activity_main.*

/**
 * Description:
 */
class MainActivity : BaseActivity(),View.OnClickListener {
    private val TAG = "MainActivity"

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        initListener()

        pickerNp.maxValue = 20
        pickerNp.minValue = 10
        pickerNp.value = 11
        pickerNp.wrapSelectorWheel = true
        pickerNp.dividerDrawable = null
        pickerNp.descendantFocusability = ViewGroup.FOCUS_BLOCK_DESCENDANTS

    }

    private fun initListener(){
        wifiBtn.setOnClickListener(this)
        test1Btn.setOnClickListener(this)
        test2Btn.setOnClickListener(this)
        test3Btn.setOnClickListener(this)
    }


    override fun onClick(view: View) {
        when (view.id) {
            R.id.wifiBtn -> Route.j2WifiConnectActivity(this)
            R.id.test1Btn -> {
                val intent = Intent(this.applicationContext, WifiConnectActivity2::class.java)
                intent.action = Intent.ACTION_VIEW
                val bitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_launcher)
                ShortcutUtils.addShortcut(applicationContext, "1234456", bitmap, intent)
            }
            R.id.test2Btn -> {
                DatePickerDialog(this)
                    .setBackground(DatePickerDialog.STACK)
                    .setTitle("时间选择")
                    .setDataTimeFormat("yyyy年MM月dd日 c")
                    .show()
            }
            R.id.test3Btn -> {
            }
            else -> {
            }
        }
    }
}